<template>
  <div class="ma-content-block p-4">
    <ma-crud :options="crud" :columns="columns" ref="crudRef">

      <template #p_name="{ record }">
        {{record?.act_detail.name}}
      </template>

      <template #takeout_order_images="{ record }">
        <a-image :src="record.takeout_order_images ? $tool.showFile(record.takeout_order_images):''" height="60" width="50" />
      </template>
      <template #takeout_evaluate_images="{ record }">
        <a-image :src="record.takeout_evaluate_images ? $tool.showFile(record.takeout_evaluate_images):''" height="60"  width="50"/>
      </template>


      <a-image :src="item.value ? $tool.showFile(item.value):''" height="80" />
    </ma-crud>
  </div>
</template>

<script setup>
import {ref, reactive, onMounted} from 'vue'

import api from '@/api/prm/bwc_order.js'
import { Message } from '@arco-design/web-vue'

const crudRef = ref()


//表格
const crud = reactive({
  api: api.list,
  showIndex: false,
  // pageLayout: 'fixed',
  showTools:false,
  // tablePagination:true,
  rowSelection: {showCheckedAll: true},
  operationColumn: false,
  operationColumnWidth: 180,
  searchColNumber:3,
  add: {show: false},
  edit: {show: false},
  delete: {show: false},
  formOption: {viewType: 'drawer', width: 800},
})

//-3待确认 -2已驳回 -1已取消 1已报名 2已提交 3待审核 4已完成
const order_status = [
    {label: '待确认', value: -3},
    {label: '已驳回', value: -2},
    {label: '已取消', value: -1},
    {label: '已报名', value: 1},
    {label: '已提交', value: 2},
    {label: '待审核', value: 3},
    {label: '已完成', value: 4},
]
// 0:审核中,对应订单状态3 1:审核成功,对应订单状态4 2:审核失败,对应订单状态-2 3:待用户确认,对应订单状态-3,审核失败需要重新上传订单信息
const audit_status = [
    {label: '审核中', value: 0},
    {label: '审核成功', value: 1},
    {label: '审核失败', value: 2},
    {label: '待用户确认', value: 3},

]
const columns = reactive([
  {title: 'ID', dataIndex: 'id', addDisplay: false, editDisplay: false, width: 50, hide: true},
  {title: '用户昵称', dataIndex: 'nickname', formType: 'input', search: false, width: 80,},
  {title: '真实返现金额', dataIndex: 'real_cash_back_amount', formType: 'input', search: false, width: 80,},
  {title: '结算金额', dataIndex: 'settlement_amount', formType: 'input', search: false, width: 80,},
  {title: '流水号', dataIndex: 'order_no', formType: 'input', search: true, width: 100,},
  {title: '外卖单号', dataIndex: 'takeout_order_no', formType: 'input', search: true, width: 100,},
  {title: '商品名称', dataIndex: 'p_name', formType: 'input', search: false, width: 100,},
  {title: '订单状态', dataIndex: 'order_status', formType: 'select', dict: { data: order_status, translation: true }, search: true, width: 80,},
  {title: '审核状态', dataIndex: 'audit_status', formType: 'select', dict: { data: audit_status, translation: true }, search: true, width: 80,},
  {title: '审核反馈', dataIndex: 'audit_tips', formType: 'input', search: false, width: 80,},
  {title: '取消原因', dataIndex: 'cancel_reason', formType: 'input', search: false, width: 80,},
  {title: '订单完成截图', dataIndex: 'takeout_order_images', formType: 'input', search: false, width: 80,},
  {title: '订单评价截图', dataIndex: 'takeout_evaluate_images', formType: 'input', search: false, width: 80,},

  {title: '结算状态', dataIndex: 'trans_status', dict: { data: [{label: '结算失败', value: -1}, {label: '待结算', value: 0}, {label: '已结算', value: 1}], translation: true }, search: true, width: 200},
  {title: '结转描述', dataIndex: 'trans_remark', search: false, width: 200},
  {
    title: '下单时间', dataIndex: 'created_at', addDisplay: false, editDisplay: false,
    search: false, formType: 'range', width: 180
  },
  {
    title: '更新时间', dataIndex: 'updated_at', addDisplay: false, editDisplay: false,
    search: false, formType: 'range', width: 180
  }])

</script>

<script>
export default {name: 'prm:bwc_order'}
</script>

<style scoped>

</style>
